/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz;

import Entidades.Bomberos;
import Entidades.Entidad;
import Entidades.Hospital;
import Entidades.Policia;
import Entidades.Ubicacion;
import Negocio.*;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.beans.PropertyVetoException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import negocio.Solicitante;
import negocio.GestorSolicitante;
import negocio.Problema;
import negocio.GestorProblema;


/**
 *
 * @author INGENIERIA
 */
public class InterfazLlamada extends javax.swing.JInternalFrame {
    DefaultTableModel modeloproblema = new DefaultTableModel();
    DefaultTableModel modeloproducto = new DefaultTableModel();
    DefaultTableModel modeloingreso = new DefaultTableModel();
    Calendar Cal= Calendar.getInstance();
    String fecha=null;
    int numero=0;
    String direccion=null;
    String cedula=null;
    Double total=0.0D;
    DefaultComboBoxModel modeloProductoCombo=new DefaultComboBoxModel();
    GestorProblema problemas=new GestorProblema();
    Problema problema=new Problema();
    ArrayList listaSolicitanteProblema = new ArrayList();
    ArrayList listaProblemas=new ArrayList();
    GestorSolicitante solicitantes=new GestorSolicitante();
    Solicitante solicitante=new Solicitante();
    ArrayList listaSolicitantes=new ArrayList();
    boolean operacion=false;
    ArrayList listaProb=new ArrayList();
    ArrayList listaSol=new ArrayList();
    Object listaAtributos[]=new Object[4];
    ImageIcon ImgValido=new ImageIcon(getClass().getResource( "/Imagenes/CampoValido.jpg" ));
    ImageIcon ImgInvalido=new ImageIcon(getClass().getResource( "/Imagenes/CampoInvalido.jpg" ));
    DefaultListModel modeloproductolista=new DefaultListModel();
    DefaultComboBoxModel modeloClienteCombo=new DefaultComboBoxModel();
    //mipanel panelMenuI = new mipanel(490, 44,"/imagenes/tab_bar.jpg");
    String cedulaSolicitante=null;
    mipanel bgrTitulo = new mipanel(821, 36,"/imagenes/title_panel1.jpg");    
    //mipanel panelMensajeI = new mipanel(474, 33,"/imagenes/title_panel.jpg");
    InterfazSolicitante interfaz_sol = new InterfazSolicitante();

    
    public GestorSolicitante getGestorSolicitante() {
        return solicitantes;
    }

    public void setGestorSolicitante(GestorSolicitante gestorp) {
        this.solicitantes = gestorp;
    }

    public GestorProblema getGestorProblema() {
        return problemas;
    }

    public void setGestorProblema(GestorProblema gestore) {
        this.problemas = gestore;
    }
      

    public boolean isOperacion() {
        return operacion;
    }

    public void setOperacion(boolean operacion) {
        this.operacion = operacion;
    }

    public Solicitante getSolicitante() {
        return solicitante;
    }

    public void setSolicitante(Solicitante pcombo) {
        this.solicitante = pcombo;
    }
    
    /**
     * Creates new form IngresoProyecto
     */
    public InterfazLlamada() {
        initComponents();
        pnlMensaje.setVisible(false);
        pnlIngresoFactura.setVisible(false);
        pnlMenu.setVisible(true);
        tblIngreso.setModel(modeloingreso);
        modeloproblema.addColumn("Cedula");
        modeloproblema.addColumn("Numero");
        modeloproblema.addColumn("Fecha");
        modeloproblema.addColumn("Total");
        modeloproducto.addColumn("id");
        modeloproducto.addColumn("Producto");
        modeloproducto.addColumn("Cantidad");
        modeloproducto.addColumn("Precio Unitario");
        modeloproducto.addColumn("Precio Total");
        modeloingreso.addColumn("Cantida");
        modeloingreso.addColumn("codigoProducto");
        modeloingreso.addColumn("nombre");
        modeloingreso.addColumn("Precio Unitario");
        modeloingreso.addColumn("Precio Total");
        jPanel1.add(bgrTitulo);
        jPanel1.repaint();        
        //pnlMensaje.add(panelMensajeI);
        //pnlMensaje.repaint();
        //pnlMenu.add(panelMenuI);
        //pnlMenu.repaint();
        agregarFacturas();
    }

    public void limpiar()
    {
        int tamaño= modeloproblema.getRowCount();
        for(int i=0;i<tamaño;i++)
        {
            modeloproblema.removeRow(0);
        }
    }
    public void limpiarproductos()
    {
        int tamaño= modeloproducto.getRowCount();
        for(int i=0;i<tamaño;i++)
        {
            modeloproducto.removeRow(0);
        }
    }


    public void limpiaringreso()
    {
        int tamaño= modeloingreso.getRowCount();
        for(int i=0;i<tamaño;i++)
        {
            modeloingreso.removeRow(0);
        }
    }

    public void agregarFacturas()
    {
        limpiar();
        //System.out.println(getGestorp().getLista().size()+"");
        problemas.listar();
        listaProb=problemas.getFacturas();
        Iterator it = listaProb.iterator();
        while (it.hasNext())
        {
            Problema c=(Problema) it.next();
            Object atributosPro[]={c.getEstado(),c.getFecha(),c.getLugar(),c.getMotivo(),c.getFecha(),c.getId()};
            modeloproblema.addRow(atributosPro);

        }

        lblTitulo.setText("FACTURAS: Ingreso Modificación Eliminación");
        System.out.println("Numero:"+modeloproblema.getRowCount());
    }
//    public void agregarProductosFactura()
//    {
//        limpiar();
//        //System.out.println(getGestorp().getLista().size()+"");
//        problema.setId(Integer.parseInt(tblProblemas.getValueAt(tblProblemas.getSelectedRow(), 1).toString()));
//        solicitante.buscar();
//        listaSolicitanteProblema=problema.getMotivo();
//        listaProblemas=problema.getId();
//
//        for (int i=0;i<listaSolicitanteProblema.size();i++)
//        {
//            Solicitante c=(Solicitante) listaSolicitanteProblema.get(i);
//            int cantidad= Integer.parseInt(listaProblemas.get(i).toString());
//            Object atributosSol[]={cantidad, c.getCodigo(),c.getNombre(),c.getPreciou(),c.getPreciou()*cantidad};
//            modeloingreso.addRow(atributosSol);
//        }
//        lblTitulo.setText("FACTURAS: Ingreso Modificación Eliminación");
//        System.out.println("Numero:"+modeloproblema.getRowCount());
//    }
        ArrayList listap=new ArrayList();
        ArrayList listac=new ArrayList();
//    public void agregarProductos(int numerofactura)
//    {
//
//        limpiarproductos();
//        //System.out.println(getGestorp().getLista().size()+"");
//        problema.setId(numerofactura);
//        problema.buscar();
//        listap=problema.buscarListaProductos();
//        listac=problema.getCantidades();
//        for (int i=0;i<listap.size();i++)
//        {
//            Producto c=(Producto) listap.get(i);
//            c.buscar();
//            int cantidad= problema.buscarCantidad(c.getCodigo());
//            Object atributosprod[]={c.getCodigo(),c.getNombre(),cantidad,c.getPreciou(),c.getPreciou()*cantidad};
//            modeloproducto.addRow(atributosprod);
//        }
//    }
//    public void agregarClientesCombo()
//    {
//        modeloClienteCombo.removeAllElements();
//        clientes.listar();
//        listaClientes=clientes.getClientes();
//        Iterator it = listaClientes.iterator();
//        while (it.hasNext())
//        {
//            Cliente c=(Cliente) it.next();
//            modeloClienteCombo.addElement(c.getCedula());
//        }
//        cmbEstado.setModel(modeloClienteCombo);
//    }
//    public void agregarProductosCombo()
//    {
//        modeloProductoCombo.removeAllElements();
//        solicitantes.listar();
//        listaSolicitantes=solicitantes.getProductos();
//        Iterator it = listaSolicitantes.iterator();
//        while (it.hasNext())
//        {
//            Producto p=(Producto) it.next();
//            modeloProductoCombo.addElement(p.getNombre());
//        }
//        cmbProblema.setModel(modeloProductoCombo);
//    }
    public boolean Validar()
    {
        boolean resp=false;
        if(valFecha.getIcon().equals(ImgInvalido) || valcmbCli.getIcon().equals(ImgInvalido) || valNum.getIcon().equals(ImgInvalido) || modeloingreso.getRowCount()<1)
        {
            resp=false;

        }
        else
        {
            resp=true;
        }
        return resp;
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlMensaje = new javax.swing.JPanel();
        lblMensaje = new javax.swing.JLabel();
        btnCerrarMensaje = new javax.swing.JButton();
        lblVerificar = new javax.swing.JLabel();
        pnlMenu = new javax.swing.JPanel();
        btnIngresar = new javax.swing.JButton();
        pnlIngresoFactura = new javax.swing.JPanel();
        txtDireccion = new javax.swing.JTextField();
        lblPorcentajeAvance1 = new javax.swing.JLabel();
        lblProyecto = new javax.swing.JLabel();
        lblCodigo1 = new javax.swing.JLabel();
        txtCedula = new javax.swing.JTextField();
        btnNuevo = new javax.swing.JButton();
        btnGrabar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        cmbEstado = new javax.swing.JComboBox();
        valcmbCli = new javax.swing.JLabel();
        valFecha = new javax.swing.JLabel();
        valDir = new javax.swing.JLabel();
        lblLibro = new javax.swing.JLabel();
        cmbProblema = new javax.swing.JComboBox();
        valcmbPro = new javax.swing.JLabel();
        btnAgregar = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblIngreso = new javax.swing.JTable();
        valNum = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        txtDescripcion = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        lblTitulo = new javax.swing.JLabel();

        setBackground(new java.awt.Color(250, 249, 242));
        setBorder(null);
        setForeground(new java.awt.Color(255, 255, 102));

        pnlMensaje.setBackground(new java.awt.Color(250, 247, 247));
        pnlMensaje.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lblMensaje.setBackground(new java.awt.Color(250, 247, 247));

        btnCerrarMensaje.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cerrar.jpg"))); // NOI18N
        btnCerrarMensaje.setToolTipText("Cerrar Mensaje");
        btnCerrarMensaje.setBorder(null);
        btnCerrarMensaje.setOpaque(false);
        btnCerrarMensaje.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarMensajeActionPerformed(evt);
            }
        });

        lblVerificar.setAutoscrolls(true);

        javax.swing.GroupLayout pnlMensajeLayout = new javax.swing.GroupLayout(pnlMensaje);
        pnlMensaje.setLayout(pnlMensajeLayout);
        pnlMensajeLayout.setHorizontalGroup(
            pnlMensajeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMensajeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 393, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblVerificar, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(btnCerrarMensaje))
        );
        pnlMensajeLayout.setVerticalGroup(
            pnlMensajeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlMensajeLayout.createSequentialGroup()
                .addGroup(pnlMensajeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblMensaje, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblVerificar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnCerrarMensaje, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap())
        );

        pnlMenu.setBackground(new java.awt.Color(250, 247, 247));
        pnlMenu.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        pnlMenu.setPreferredSize(new java.awt.Dimension(490, 44));

        btnIngresar.setBackground(new java.awt.Color(250, 247, 247));
        btnIngresar.setForeground(new java.awt.Color(255, 255, 255));
        btnIngresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cmd_ingresar.jpg"))); // NOI18N
        btnIngresar.setBorder(null);
        btnIngresar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        btnIngresar.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
        btnIngresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIngresarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlMenuLayout = new javax.swing.GroupLayout(pnlMenu);
        pnlMenu.setLayout(pnlMenuLayout);
        pnlMenuLayout.setHorizontalGroup(
            pnlMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlMenuLayout.createSequentialGroup()
                .addContainerGap(200, Short.MAX_VALUE)
                .addComponent(btnIngresar)
                .addGap(169, 169, 169))
        );
        pnlMenuLayout.setVerticalGroup(
            pnlMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMenuLayout.createSequentialGroup()
                .addComponent(btnIngresar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlIngresoFactura.setBackground(new java.awt.Color(250, 247, 247));
        pnlIngresoFactura.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Ingreso De Problema"));

        txtDireccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDireccionActionPerformed(evt);
            }
        });
        txtDireccion.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDireccionFocusLost(evt);
            }
        });

        lblPorcentajeAvance1.setText("Direccion:");

        lblProyecto.setText("Estado:");

        lblCodigo1.setText("Cedula Solicitante:");

        txtCedula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCedulaActionPerformed(evt);
            }
        });
        txtCedula.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtCedulaFocusLost(evt);
            }
        });

        btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cmd_nuevo.jpg"))); // NOI18N
        btnNuevo.setBorder(null);
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        btnGrabar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cmd_grabar.jpg"))); // NOI18N
        btnGrabar.setBorder(null);
        btnGrabar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGrabarActionPerformed(evt);
            }
        });

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cmd_cancel.jpg"))); // NOI18N
        btnCancelar.setBorder(null);
        btnCancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCancelarMouseClicked(evt);
            }
        });
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        cmbEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "propuesto", "aprobado", "incorporado" }));
        cmbEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbEstadoActionPerformed(evt);
            }
        });

        valcmbCli.setBackground(new java.awt.Color(250, 247, 247));
        valcmbCli.setOpaque(true);

        valFecha.setBackground(new java.awt.Color(250, 247, 247));
        valFecha.setOpaque(true);

        valDir.setBackground(new java.awt.Color(250, 247, 247));
        valDir.setOpaque(true);

        lblLibro.setText("Grado del problema:");

        cmbProblema.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "leve", "regular", "grave" }));
        cmbProblema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbProblemaActionPerformed(evt);
            }
        });
        cmbProblema.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                cmbProblemaFocusLost(evt);
            }
        });

        valcmbPro.setBackground(new java.awt.Color(250, 247, 247));
        valcmbPro.setOpaque(true);

        btnAgregar.setBackground(new java.awt.Color(250, 247, 247));
        btnAgregar.setText("Agregar");
        btnAgregar.setBorder(null);
        btnAgregar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        btnAgregar.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarActionPerformed(evt);
            }
        });

        tblIngreso.setAutoCreateRowSorter(true);
        tblIngreso.setBackground(new java.awt.Color(250, 249, 242));
        tblIngreso.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        tblIngreso.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Estado", "Cedula solicitante", "fecha", "Grado del problema", "Direccion", "Descripcion"
            }
        ));
        tblIngreso.setColumnSelectionAllowed(true);
        tblIngreso.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        tblIngreso.setGridColor(new java.awt.Color(51, 51, 51));
        tblIngreso.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblIngresoMouseClicked(evt);
            }
        });
        tblIngreso.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                tblIngresoInputMethodTextChanged(evt);
            }
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
        });
        tblIngreso.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                tblIngresoPropertyChange(evt);
            }
        });
        tblIngreso.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblIngresoKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tblIngresoKeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(tblIngreso);
        tblIngreso.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        valNum.setBackground(new java.awt.Color(250, 247, 247));
        valNum.setOpaque(true);

        jLabel1.setText("Descripcion:");

        javax.swing.GroupLayout pnlIngresoFacturaLayout = new javax.swing.GroupLayout(pnlIngresoFactura);
        pnlIngresoFactura.setLayout(pnlIngresoFacturaLayout);
        pnlIngresoFacturaLayout.setHorizontalGroup(
            pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                        .addGap(96, 96, 96)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lblProyecto)
                            .addComponent(lblCodigo1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(valFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(valcmbCli, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(valNum, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                                .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblPorcentajeAvance1)
                                    .addComponent(lblLibro))
                                .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                                        .addGap(103, 103, 103)
                                        .addComponent(valcmbPro, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                                        .addGap(141, 141, 141)
                                        .addComponent(valDir, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(cmbProblema, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                                    .addComponent(jLabel1)
                                    .addGap(48, 48, 48)
                                    .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(15, 15, 15)))
                            .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                                .addGap(106, 106, 106)
                                .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                        .addGap(104, 104, 104)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 427, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                                .addComponent(btnNuevo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnGrabar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnCancelar)))))
                .addContainerGap(187, Short.MAX_VALUE))
        );
        pnlIngresoFacturaLayout.setVerticalGroup(
            pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(valcmbCli, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cmbEstado)
                                .addComponent(lblProyecto)))
                        .addGap(18, 18, 18)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCedula, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                            .addComponent(lblCodigo1)
                            .addComponent(valNum, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE))
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlIngresoFacturaLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(valFecha, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)
                                .addGap(38, 38, 38))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlIngresoFacturaLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlIngresoFacturaLayout.createSequentialGroup()
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblLibro)
                                .addComponent(cmbProblema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(valcmbPro, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(valDir, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                            .addComponent(txtDireccion, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                            .addComponent(lblPorcentajeAvance1, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(42, 42, 42)))
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38)
                .addGroup(pnlIngresoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnNuevo)
                    .addComponent(btnGrabar)
                    .addComponent(btnCancelar))
                .addGap(32, 32, 32))
        );

        jPanel1.setBackground(new java.awt.Color(250, 249, 242));

        lblTitulo.setText("Llamadas: Ingreso Modificación Eliminación");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(72, 72, 72)
                .addComponent(lblTitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 919, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblTitulo)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(148, 148, 148)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlIngresoFactura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 474, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(pnlIngresoFactura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(285, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCerrarMensajeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarMensajeActionPerformed
        // TODO add your handling code here:
        lblMensaje.setText("");
        pnlMensaje.setVisible(false);

    }//GEN-LAST:event_btnCerrarMensajeActionPerformed

   
           
    private void txtDireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDireccionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDireccionActionPerformed

    private void txtCedulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCedulaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtCedulaActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
        // TODO add your handling code here:
        limpiaringreso();
        cmbEstado.setSelectedIndex(-1);
        txtCedula.setText(null);
        txtDireccion.setText(null);
        cmbProblema.setSelectedIndex(-1);
        fecha= Cal.get(Cal.YEAR)+"/"+(Cal.get(Cal.MONTH)+1)+"/"+Cal.get(Cal.DATE);
        valFecha.setIcon(ImgValido);
        valcmbCli.setIcon(ImgInvalido);
        valDir.setIcon(ImgInvalido);
        valNum.setIcon(ImgInvalido);
        valcmbPro.setIcon(ImgInvalido);
    }//GEN-LAST:event_btnNuevoActionPerformed

    private void btnGrabarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGrabarActionPerformed
        // TODO add your handling code here:
       if (Validar()==true){
            cedulaSolicitante= this.txtCedula.getText();
            String estado= (String) this.cmbEstado.getSelectedItem();
            String nivel= (String) this.cmbProblema.getSelectedItem();
            numero = Integer.parseInt(this.txtCedula.getText());
            Calendar Cal= Calendar.getInstance();
            String fechahora;
            fechahora= Cal.get(Cal.DATE)+"/"+(Cal.get(Cal.MONTH)+1)+"/"+Cal.get(Cal.YEAR)+" "+Cal.get(Cal.HOUR_OF_DAY)+":"+Cal.get(Cal.MINUTE)+":"+Cal.get(Cal.SECOND);
            solicitante.setCedula(cedulaSolicitante);
            solicitante.buscar();

            if (operacion == false) {
                problema.setId("1");
                problema.setFecha(fecha);
                problema.setEstado(estado);
                problema.setLugar(this.txtDireccion.getText());
                problema.setMotivo(this.txtDescripcion.getText());
                problema.setNivel(nivel);
                problema.setNombre(solicitante.getNombre());
                problema.buscar();
//                listaSolicitanteProblema=problema.getProductos();
//                listaProblemas=problema.getCantidades();
                for (int i=0;i<listaSolicitanteProblema.size();i++)
                {
//                    Producto c=(Producto) listaSolicitanteProblema.get(i);
                    int cantidad= Integer.parseInt(listaProblemas.get(i)+"");
//                    problema.asignarrelacion(c, cantidad);
                }
//                problema.borrar();
                lblMensaje.setText("Factura guardado Satisfactoriamente");
            } else {
//                problema.modificar();
                lblMensaje.setText("Factura Modificada Satisfactoriamente");
                btnCancelarActionPerformed(evt);
            }
            lblVerificar.setIcon(new ImageIcon( getClass().getResource( "/Imagenes/bien.jpg" )));


        } else{

            if(operacion==false) {
                lblMensaje.setText("Error: No se pudo guardar la Ciudad");
            } else {
                lblMensaje.setText("Error: No se pudo modificar la Ciudad");
            }
            lblVerificar.setIcon(new ImageIcon( getClass().getResource( "/Imagenes/Error.jpg" )));
        }
        pnlMensaje.setVisible(true);
    }//GEN-LAST:event_btnGrabarActionPerformed

    private void btnCancelarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnCancelarMouseClicked

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        // TODO add your handling code here:
        pnlIngresoFactura.setVisible(false);
        agregarFacturas();
        btnNuevoActionPerformed(evt);
//        pnlModificacion.setVisible(true);
        pnlMenu.setVisible(true);
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void cmbEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbEstadoActionPerformed
        // TODO add your handling code here:
        if (operacion==false && cmbEstado.getSelectedIndex()!=-1){
            txtCedula.setEditable(true);
            valcmbCli.setIcon(ImgValido);
        }
        else if(operacion == true && cmbEstado.getSelectedIndex() != -1)
        {
            cmbEstado.setEnabled(false);
            txtCedula.setEditable(true);
            valcmbCli.setIcon(ImgValido);
        }
        else
        {
            valcmbCli.setIcon(ImgInvalido);
        }
        
    }//GEN-LAST:event_cmbEstadoActionPerformed

     public void agregarElementos()
    {
        limpiar();
        //System.out.println(getGestorp().getLista().size()+"");
        problemas.listar();
        listaProb=problemas.getFacturas();
        Iterator it = listaProb.iterator();
        while (it.hasNext())
        {
            Problema p=(Problema) it.next();
          
            Object atributosFac[]={p.getId(),p.getEstado(),p.getFecha(),p.getLugar(),p.getMotivo(),p.getNombre()};
            modeloproblema.addRow(atributosFac);
            
        }
        System.out.println("Numero:"+modeloproblema.getRowCount());
    }
    
    private void txtDireccionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDireccionFocusLost
        // TODO add your handling code here:
        try{
        String.valueOf(txtDireccion.getText());
        valDir.setIcon(ImgValido);
        } catch (Exception ex)
        {
         valDir.setIcon(ImgInvalido);
        }
    }//GEN-LAST:event_txtDireccionFocusLost

    private void cmbProblemaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cmbProblemaFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbProblemaFocusLost

    private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarActionPerformed
        // TODO add your handling code here:

//        if (valcmbPro.getIcon().equals(ImgValido) && valDir.getIcon().equals(ImgValido))
//        {
//            if(s.buscar(this.txtCedula.getText())==0)
//            {
//                fechahora= Cal.get(Cal.DATE)+"/"+(Cal.get(Cal.MONTH)+1)+"/"+Cal.get(Cal.YEAR)+" "+Cal.get(Cal.HOUR_OF_DAY)+":"+Cal.get(Cal.MINUTE)+":"+Cal.get(Cal.SECOND);
//               // String pro= (String) cmbProblema.getSelectedItem();
//               // p.setNombre(pro);
//                if(this.cmbProblema.getSelectedIndex()==0) {  
//                    problema="leve";
//                     Ubicacion a = new Ubicacion();
//                     a.agregar(new Bomberos());
//        
//                    Entidad entidad = new Entidad();
//                    entidad.setEstado("propuesto");
//        
//                    a.notificar();
//                }
//                if(this.cmbProblema.getSelectedIndex()==1){   
//                    problema="regular";
//                    Ubicacion a = new Ubicacion();
//                    a.agregar(new Bomberos());
//                    a.agregar(new Hospital());
//                    Entidad entidad = new Entidad();
//                    entidad.setEstado("propuesto");
//                    a.notificar();
//                }
//                
//                if(this.cmbProblema.getSelectedIndex()==2){
//                   problema="grave";
//                    problema="regular";
//                    Ubicacion a = new Ubicacion();
//                    a.agregar(new Bomberos());
//                    a.agregar(new Hospital());
//                    a.agregar(new Policia());        
//                    Entidad entidad = new Entidad();
//                    entidad.setEstado("propuesto");        
//                    a.notificar();
//                }
//                
//                
//              
//                
//            }
//            else{
//                 JOptionPane.showMessageDialog(this, "El usuario no e encuentra.!!! INGRESE EL USUARIO");
//                 val=1;
//            }
//           
//                
//            if(val==0){
//                
//                valDir.setIcon(ImgInvalido);
//                direccion=txtDireccion.getText();           
////                problema.agregarProductos(p, direccion+"");
////                Object atributosIng[]={direccion,p.getCodigo(),p.getNombre(),p.getPreciou(),p.getPreciou()*direccion};
////                modeloingreso.addRow(atributosIng);
//                this.txtDireccion.setText("");
//                cmbProblema.setSelectedIndex(-1);
//                lblMensaje.setText("Producto Agregado Correctamente");
//                lblVerificar.setIcon(new ImageIcon( getClass().getResource( "/Imagenes/bien.jpg" )));
//                pnlMensaje.setVisible(true);
//                this.txtCedula.setEditable(false);
//            }else{
//                this.lblMensaje.setText("Elemento repetido");
//                this.lblMensaje.setVisible(true);
//                lblVerificar.setIcon(new ImageIcon( getClass().getResource( "/Imagenes/Error.jpg" )));
//            }
//                
//        }
//        else{
//            lblVerificar.setIcon(new ImageIcon( getClass().getResource( "/Imagenes/Error.jpg" )));
//            lblMensaje.setText("Error: No se puede agregar 'Elija el prodcuto y su cantidad'");
//            pnlMensaje.setVisible(true);
//        }
        
         int val=0;
        Calendar Cal= Calendar.getInstance();
        Solicitante s=new Solicitante();
        String fechahora;
        Problema p=new Problema();
        if (valcmbPro.getIcon().equals(ImgValido) && valDir.getIcon().equals(ImgValido))
        {
            if(s.buscar(this.txtCedula.getText())==0)
            {
                fechahora= Cal.get(Cal.DATE)+"/"+(Cal.get(Cal.MONTH)+1)+"/"+Cal.get(Cal.YEAR)+" "+Cal.get(Cal.HOUR_OF_DAY)+":"+Cal.get(Cal.MINUTE)+":"+Cal.get(Cal.SECOND);
               // String pro= (String) cmbProblema.getSelectedItem();
               // p.setNombre(pro);
                String cedula=txtCedula.getText();
                String direccion=txtDireccion.getText();
                String descripcion=txtDescripcion.getText();
                String est=(String)this.cmbEstado.getSelectedItem();
                System.out.println("valorrrr"+est);
                int grado=this.cmbProblema.getSelectedIndex()+1;
                p.setEstado(est);
                p.setFecha(fechahora);
                p.setLugar(direccion);
                p.setMotivo(descripcion);
                p.setNivel(String.valueOf(grado));
                p.setNombre(cedula);
                p.setId("");
                p.grabar(solicitante);
                
            }
            else{
                 JOptionPane.showMessageDialog(this, "El usuario no e encuentra.!!! INGRESE EL USUARIO");
                 val=1;
            }
        }
        
}//GEN-LAST:event_btnAgregarActionPerformed

    private void tblIngresoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblIngresoMouseClicked
        // TODO add your handling code here:


    }//GEN-LAST:event_tblIngresoMouseClicked

    private void tblIngresoInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_tblIngresoInputMethodTextChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_tblIngresoInputMethodTextChanged

    private void tblIngresoPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_tblIngresoPropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_tblIngresoPropertyChange

    private void tblIngresoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblIngresoKeyReleased
        // TODO add your handling code here:

    }//GEN-LAST:event_tblIngresoKeyReleased

    private void tblIngresoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblIngresoKeyPressed
        // TODO add your handling code here:

    }//GEN-LAST:event_tblIngresoKeyPressed

    private void btnIngresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIngresarActionPerformed
        // TODO add your handling code here:
        operacion=false;
        pnlIngresoFactura.setVisible(true);
        pnlMenu.setVisible(false);
        cmbEstado.setSelectedIndex(-1);
        cmbProblema.setSelectedIndex(-1);
        cmbEstado.setEnabled(true);
        txtCedula.setEditable(true);
        fecha= Cal.get(Cal.YEAR)+"/"+(Cal.get(Cal.MONTH)+1)+"/"+Cal.get(Cal.DATE);
//        problema.borrar();
        txtCedula.setText(null);
        valFecha.setIcon(ImgValido);
        valcmbCli.setIcon(ImgInvalido);
        valDir.setIcon(ImgInvalido);
        valNum.setIcon(ImgInvalido);
        valcmbPro.setIcon(ImgInvalido);

}//GEN-LAST:event_btnIngresarActionPerformed

    private void txtCedulaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtCedulaFocusLost
        // TODO add your handling code here:
        try{
        Double.parseDouble(txtCedula.getText());
        valNum.setIcon(ImgValido);
        } catch (Exception ex)
        {
         valNum.setIcon(ImgInvalido);
        }
    }//GEN-LAST:event_txtCedulaFocusLost

    private void cmbProblemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbProblemaActionPerformed
        // TODO add your handling code here:
        if (operacion==false && cmbProblema.getSelectedIndex()!=-1){
            txtDireccion.setEditable(true);
            valcmbPro.setIcon(ImgValido);
        }
        else
        {
            valcmbPro.setIcon(ImgInvalido);
        }
    }//GEN-LAST:event_cmbProblemaActionPerformed

    public class mipanel extends javax.swing.JPanel {
        String ruta;
        public mipanel(int ancho, int alto, String ruta){
            this.setSize(ancho,alto);
            this.ruta=ruta;           
        }

        @Override
        public void paint(Graphics g){
            
            Dimension tamanio = getSize();
            ImageIcon imagenFondo = new ImageIcon(getClass().getResource(ruta));
            g.drawImage(imagenFondo.getImage(),0,0,tamanio.width, tamanio.height, null);
            setOpaque(false);
            super.paintComponent(g);

        }
        
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnCerrarMensaje;
    private javax.swing.JButton btnGrabar;
    private javax.swing.JButton btnIngresar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JComboBox cmbProblema;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblCodigo1;
    private javax.swing.JLabel lblLibro;
    private javax.swing.JLabel lblMensaje;
    private javax.swing.JLabel lblPorcentajeAvance1;
    private javax.swing.JLabel lblProyecto;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JLabel lblVerificar;
    private javax.swing.JPanel pnlIngresoFactura;
    private javax.swing.JPanel pnlMensaje;
    private javax.swing.JPanel pnlMenu;
    private javax.swing.JTable tblIngreso;
    private javax.swing.JTextField txtCedula;
    private javax.swing.JTextField txtDescripcion;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JLabel valDir;
    private javax.swing.JLabel valFecha;
    private javax.swing.JLabel valNum;
    private javax.swing.JLabel valcmbCli;
    private javax.swing.JLabel valcmbPro;
    // End of variables declaration//GEN-END:variables
}


